<template>
  <view>
    <view class="flex-block flex-col" :style="{height: screenHeight + 'px'}">
      <view style="flex: 1; height: 0rpx; overflow: scroll;">
        <tab1 v-show="currentIndex == 0" />
        <tab2 v-if="currentIndex == 1" />
        <tab3 v-if="currentIndex == 2" />
      </view>
      <view>
        <y-tabbar v-model:activeIndex="currentIndex"></y-tabbar>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { onShow, onHide, onLoad } from "@dcloudio/uni-app"
import { loginInit } from '@/hooks/index.js'
import cache from '@/utils/cached.js'
import tab1 from './tab1'
import tab2 from './tab2'
import tab3 from './tab3'

loginInit()

const currentIndex = ref(0)
const list = ref([
  {
    icon: "crown",
  },
  {
    icon: "shopping",
    badge: {
      text: '100',
      max: 99,
    }
  },
  {
    icon: "user",
  },
])
const screenHeight = computed(() => uni.getSystemInfoSync().screenHeight - uni.getSystemInfoSync().safeAreaInsets.bottom)

onLoad((options) => {
  currentIndex.value = options.index || 0

  showProfileTips()
})
async function showProfileTips() {
  if (cache.getUserInfo()?.nickName == '微信用户') {
    const { confirm, cancel } = await uni.showModal({
      title: '提示',
      content: '请尽快完善用户资料,以便获得更好的用户体验.',
      cancelText: '下次一定',
      confirmText: '马上完善'
    })

    if (confirm) {
      uni.navigateTo({
        url: '/pages/update-profile/update-profile'
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
</style>